using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Marlimer.Logical.Comercial;
using Marlimer.Logical.Universal;
using Marlimer.Logical.Sistema;
using Marlimer.Common;
using Marlimer.Comercial.Reportes.Crystals; 

namespace Marlimer.Comercial.Reportes.Formularios
{
    public partial class frm_ResumenVentaXRuta : Form
    {

        List<InfoParamRpt> paramsrpt = new List<InfoParamRpt>();

        rptResumenVentaByFecha RptResumenVentaByFecha = new rptResumenVentaByFecha();

        public frm_ResumenVentaXRuta(DateTime dfec_ent)
        {
            InitializeComponent();
            dtpFecEnt.Value = dfec_ent;
            CargarReporte();
        }

        private void frm_ResumenVentaXRuta_Load(object sender, EventArgs e)
        {
            //dtpFecEnt.Value = DateTime.Today;
            this.Location = new Point(0, 0);
        }

        private void tstComandos_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            int indice = tstComandos.Items.IndexOf(e.ClickedItem);
            switch (indice)
            {
                case 0:     //nuevo
                    {
                        nuevaBusqueda();
                        break;
                    }
                case 1:     //imprimir o mostrar
                    {
                        CargarReporte();
                        break;
                    }
                case 2:
                    {
                        Util.exportReporte(RptResumenVentaByFecha); 
                        break;
                    }
            }
        }

        private void nuevaBusqueda()
        {
            dtpFecEnt.Focus();  
        }

        private void CargarReporte()
        {
            //verificamos que se ingresen todos los datos.
            paramsrpt.Clear();
            paramsrpt.Add(new InfoParamRpt("@dfecha", dtpFecEnt.Value, true));

            try
            {
                crpReporte.ReportSource = Util.setRptParams(RptResumenVentaByFecha, paramsrpt);
                tblExportar.Enabled = true;
            }
            catch (Exception ex)
            {
                tblExportar.Enabled = false;
            }

        }

    }
}